package puyu.manage.service.security.service;



import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import puyu.manage.service.security.LoginUser;
import puyu.manage.service.utils.redis.RedisCache;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;


public abstract class DefaultCommonLogin implements CommonLogin {


    @Autowired(required = false)
    private RedisCache redisCache;

    @Autowired(required = false)
    private TokenService tokenService;


    /**
     * 数字0
     */
    public static final String NUMBER_0 = "0";

    /**
     * 数字1
     */
    public static final String NUMBER_1 = "1";
    /**
     * 数字1
     */
    public static final String NUMBER_9 = "9";

    @Override
    public Map<String, Object> loginOverTime(Authentication authentication, String username, String type) {
        Map<String, Object> map = new HashMap<>(1);
        LoginUser loginUser = (LoginUser) authentication.getPrincipal();
        // 生成token
        map.put("token", tokenService.createToken(loginUser, type));
        return map;
    }

}
